package imlayer

import (
    "strconv"
	"encoding/json"
	"dhfshop/models/isv"
)

func getActuralMediaId(srcMsgBody string) (dstMsgBody string, err error) {
	body := struct {
		MediaId string `json:"media_id"`
	}{}
	if err = json.Unmarshal([]byte(srcMsgBody), &body); err != nil {
	    return
	}
	mateSimuTaskId, e := strconv.ParseInt(body.MediaId, 10, 64) 
	if e != nil {
	    err = e
		return
	}
	mateSimuTask, e := isv.GetMateSimuTaskById(mateSimuTaskId)
	if e != nil {
	    err = e
		return
	}
	body.MediaId = mateSimuTask.MediaId
	if b, e := json.Marshal(body); e == nil {
	   dstMsgBody = string(b)
	}else{
	   err = e
	}
	return
}
